package com.jztd.servone.invoice.po;

import cn.hutool.core.util.ObjectUtil;
import cn.xbatis.db.annotations.Table;
import cn.xbatis.db.annotations.TableId;
import com.jztd.servone.invoice.param.InvoiceTitleParam;
import lombok.Data;

@Data
@Table
public class InvoiceTitle {
    /**
     * 主键ID
     */
    @TableId
    private int id;
    /**
     * 抬头名称
     */
    private String titleName;
    /**
     * 抬头类型：1-个人，2-企业
     */
    private Integer titleType;
    /**
     * 税号
     */
    private String taxNumber;
    /**
     * 是否默认：0-否，1-是
     */
    private Boolean defaultTitle;
    /**收票邮箱*/
    private String takerEmail;
    private String userId;
    private Long deleted;
    private String tenant;
    public void validateParam(InvoiceTitleParam param) {
        if (ObjectUtil.isNotEmpty(param.getTitleName())) {
            throw new RuntimeException("抬头名称不能为空");
        }
        if (param.getTitleType() == 2 && ObjectUtil.isEmpty(param.getTitleType())) {
            throw new RuntimeException("抬头类型抬头必须填写纳税人识别号");
        }
    }
}
